package com.osmino.contacts.groups.edit;

import com.osmino.contacts.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.widget.Checkable;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

public class GroupIconItem extends FrameLayout implements Checkable {

	private final ImageView mIconView;
	private final TextView mLabel;
	private final RadioButton mRadioButton;
	
	public GroupIconItem(Context context) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.group_icon_item, this);
		mIconView = (ImageView) findViewById(R.id.icon);
		mLabel = (TextView) findViewById(R.id.label);
		mRadioButton = (RadioButton) findViewById(R.id.radio_button);
	}
	
	public void setResourceAndLabel(int imageResource, String label) {
		mIconView.setImageResource(imageResource);
		mLabel.setText(label);
	}

	@Override
	public boolean isChecked() {
		return mRadioButton.isChecked();
	}

	@Override
	public void setChecked(boolean checked) {
		mRadioButton.setChecked(checked);
	}

	@Override
	public void toggle() {
		setChecked(!mRadioButton.isChecked());
	}
}
